// 记分牌类
class ScorePanel {
  score = 0
  level = 1
  scoreEle: HTMLElement
  levelEle: HTMLElement

  // 等级上限
  maxLevel: number
  rangeLevel: number

  constructor(maxLevel: number, rangeLevel: number) {
    this.scoreEle = document.querySelector('.score')!
    this.levelEle = document.querySelector('.level')!
    this.maxLevel = maxLevel
    this.rangeLevel = rangeLevel
  }

  // 加分
  addScore() {
    this.scoreEle.innerHTML = ++this.score + ''
    if (this.score % this.rangeLevel === 0) {
      this.addLevel()
    }
  }

  // 升级
  addLevel() {
    if (this.level < this.maxLevel) {
      this.levelEle.innerHTML = ++this.level + ''
    }
  }
}

export default ScorePanel